<?php


namespace app\common\tool;


class Result
{
    private static $return = [
        'code'    => 200,
        'message' => 'success',
        'data'    => [],
    ];

    /**
     * @param array $data
     * @return string
     */
    public static function success(array $data = []): string
    {
        self::$return['data'] = $data;
        return json_encode(self::$return);
    }

    /**
     * @param string $msg
     * @return string
     */
    public static function error(string $msg = ''): string
    {
        self::$return['message'] = $msg;
        return json_encode(self::$return);
    }

}